import { createStore, createLogger } from 'vuex'
// 使用数据持久化插件，导入
import createPersistedstate from 'vuex-persistedstate'
import user from './modules/user'
import cart from './modules/cart'

// 导入全局 getters
import getters from './getters'

export default createStore({
  state: {},
  // 添加 getters 选项
  getters,
  mutations: {},
  actions: {},
  modules: {
    // 注册子模块
    user,
    cart
  },
  plugins: [
    createPersistedstate({
      // 指明持久化到本地的 键名
      key: 'erabbit-client-pc-store',
      // 指明模块名、持久化哪些模块下的数据
      paths: ['user', 'cart']
      // paths: ['cart']
    }),
    createLogger()
  ]
})
